%Creates a particle with a similar specified state, and that is within the
%map.
function particle = create_particle_from_state(state, map)
    sdd = 0.5; %TODO: These two values need tuning.
    sdt = 0.5;
    newx = state(1) + sdd*randn(1, 1);
    newy = state(2) + sdd*randn(1, 1);
    newth = state(3) + sdt*randn(1, 1);
    newstate = [newx, newy, newth];
    particle = [newstate, 1];
    %Check to see if the newstate is in the map, and if not, repeat
    %generation. Should this be the case?
    if inpolygon(newx, newy, map(:, 1), map(:, 2)) ~= 1
        particle = create_particle_from_state(state, map);
    end
    return
end